﻿using System.Collections.Generic;
using System.Web.Mvc;
using WebSite.Controllers;

namespace ControleRepresentante.UnitTests.Mocks
{
    public class MockSessionConfiguration : ISessionConfiguration
    {
        private readonly Dictionary<string, object> m_Session;

        public MockSessionConfiguration()
        {
            m_Session = new Dictionary<string, object>();
        }

        public void SetValue(Controller controller, string name, object value)
        {
            m_Session[name] = value;
        }

        public T GetValue<T>(Controller controller, string name)
        {
            object value;
            return m_Session.TryGetValue(name, out value) ? (T) value : default(T);
        }

        public void Abandon(Controller controller)
        {
            m_Session.Clear();
        }
    }
}